public static Queryable<T> DirectoryRecord<T>(
this DicomDataSet dataset
)
[ExtensionAttribute()]
public:
static Queryable<T^>^ DirectoryRecordgeneric<typename T>
(
DicomDataSet^ dataset
)
dataset
The dataset that holds information on a DICOM basic directory.
T
The entity type of the query.
A object that provides LINQ based access to a DICOM basic directory.
This extension method represents a query that returns a collection of zero or more objects of a specific type. A valid DICOMDIR must be present in the dataset parameter before a query can be executed. A DICOMDIR query will be executed in the following scenarios:
The following operations are provided by the DICOMDIR LINQ Provider.
This example will show how to perform several different types of LINQ based queries on a DICOM basic directory.
using Leadtools.Dicom;
using Leadtools.Dicom.Common;
using Leadtools.Dicom.Common.Extensions;
using Leadtools;
using Leadtools.Dicom.Common.Linq.BasicDirectory;
using Leadtools.Dicom.Common.DataTypes;
using Leadtools.Codecs;
[DicomKey(DicomDirKeyType.Patient)]
public class PatientEntity
{
[Element(DicomTag.PatientID)]
public string Id
{
get;
set;
}
[Element(DicomTag.PatientName)]
public string Name
{
get;
set;
}
}
[DicomKey(DicomDirKeyType.Study)]
public class StudyEntity
{
[Element(DicomTag.PatientID)]
[DicomKey(DicomDirKeyType.Patient)]
public string PatientId
{
get;
set;
}
[Element(DicomTag.StudyDate)]
public DateTime? Date
{
get;
set;
}
[Element(DicomTag.StudyTime)]
public DateTime? Time
{
get;
set;
}
[Element(DicomTag.StudyDescription)]
public string Description
{
get;
set;
}
[Element(DicomTag.StudyInstanceUID)]
public string InstanceUID
{
get;
set;
}
[Element(DicomTag.StudyID)]
public string Id
{
get;
set;
}
[Element(DicomTag.AccessionNumber)]
public string AccessionNumber
{
get;
set;
}
}
public void TestDicomLinq()
{
DicomEngine.Startup();
using (DicomDataSet ds = new DicomDataSet())
{
ds.Load(_DicomDirFile, DicomDataSetLoadFlags.None);
FindPatients(ds);
FindStudies(ds);
FindPatientStudy(ds);
}
DicomEngine.Shutdown();
}
private void FindPatients(DicomDataSet ds)
{
var patients = from patient in ds.DirectoryRecord<PatientEntity>()
select new { Name = patient.Name, Id = patient.Id };
foreach (var patient in patients)
{
Console.WriteLine("Id: " + patient.Id);
Console.WriteLine("Name: " + patient.Name);
}
}
private void FindStudies(DicomDataSet ds)
{
var studies = from study in ds.DirectoryRecord<StudyEntity>()
select study;
foreach (var study in studies)
{
Console.WriteLine("Patient Id: " + study.PatientId);
Console.WriteLine("Accession #: " + study.AccessionNumber);
Console.WriteLine("Study Id: " + study.Id);
}
}
private void FindPatientStudy(DicomDataSet ds)
{
var query = from patient in ds.DirectoryRecord<PatientEntity>()
select new
{
patient,
Studies = from study in ds.DirectoryRecord<StudyEntity>()
where study.PatientId == patient.Id
select study
};
foreach (var item in query)
{
Console.WriteLine("Patient: " + item.patient.Id);
foreach (StudyEntity study in item.Studies)
{
Console.WriteLine(" Instance UID: " + study.InstanceUID);
}
}
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document